<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>后台 - 前端权限</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/Admin/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/Common/layui/dist/css/layui.css" media="all">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form id="signform" method="post" class="layui-form" action="{:U('Admin/Admin/b_potence')}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">管理员：<span style="color: red;">{$info.username}</span></label>
                            <input type="hidden" name="id" value="{$info.id}"/>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">前端模块</label>
                            <div>
                                <label style="font-size: 10px" class="col-sm-2 control-label">wap手机端</label>
                                <if condition="$info.is_wap eq 1">
                                    <div class="layui-form-item">
                                        <input value="wap" type="checkbox" name="module[]" title="Wap" checked>
                                    </div>
                                    <elseif condition="$info.is_wap eq 0"/>
                                    <div class="layui-form-item">
                                        <input value="wap" type="checkbox" name="module[]" title="Wap">
                                    </div>
                                </if>
                                <label style="font-size: 10px" class="col-sm-2 control-label">wab电脑端</label>
                                <if condition="$info.is_wab eq 1">
                                    <div class="layui-form-item">
                                        <input value="wab" type="checkbox" name="module[]" title="Wab" checked>
                                    </div>
                                    <elseif condition="$info.is_wab eq 0"/>
                                    <div class="layui-form-item">
                                        <input value="wab" type="checkbox" name="module[]" title="Wab">
                                    </div>
                                </if>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="hr-line-dashed"></div>
                            <button type="submit" class="btn btn-primary" style="margin-left: 80px">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Admin/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Common/js/ajaxForm.js"></script>
<script src="__PUBLIC__/Common/layer/layer.js"></script>
<script src="__PUBLIC__/Common/layui/src/layui.js"></script>
<script>


    layui.use('form', function () {
        var form = layui.form;

        //监听默认模块
        form.on('checkbox(test)', function (data) {
            console.log(data.elem); //得到checkbox原始DOM对象
            console.log(data.elem.checked); //是否被选中，true或者false
            console.log(data.value); //复选框value值，也可以通过data.elem.value得到
            console.log(data.othis); //得到美化后的DOM对象

            var elem = data.elem;
            var checked = data.elem.checked;
            var value = data.value;
            var othis = data.othis;
            if (checked == false) {
                $(othis).next('div').find('input').attr('disabled', true)
                $(othis).next('div').find('input').val("");
                form.render();
            }

            if (checked == true) {
                $(othis).next('div').find('input').attr('disabled', false)
                form.render();
            }

        });
    });


    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '.layui-input',//指定元素
            type: 'datetime'

        });
    });

    function butt() {
        if ($('#modd1').is(':checked') == false) {
            layer.alert('该模块为默认模块', {icon: 5}, function (index) {
                layer.close(index);
                $('#modd1').prop('checked');
            });
        }
    }

    $(function () {
        $('#signform').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm() {
            // if ($('.modd')) {
            //     layer.alert('请选择模块', {icon: 5}, function (index) {
            //         layer.close(index);
            //         $('#points').focus();
            //     });
            //     return false;
            // }
        }

        function complete(data) {
            if (data.status == 1) {
                $('.btn-primary').attr('disabled', 'disabled');
                layer.msg(data.info, function (index) {
                    layer.close(index);
                    window.location.href = data.url;
                });
            } else {
                layer.msg(data.info);
                return false;
            }
        }


    });
</script>
</body>

</html>